package com.razorfish.samples
{
	import com.razorfish.configuration.ConfigService;
	import com.razorfish.samples.models.TVShow;
	import flash.display.Sprite;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author derek
	 */
	public class Main extends Sprite 
	{
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			
			ConfigService.instance.init(stage);
			ConfigService.instance.addEventListener(Event.COMPLETE, onComplete);
			ConfigService.instance.registerType("Show", TVShow);
			ConfigService.instance.loadFile("fishConfig.xml");
		}
		
		private function onComplete(e:Event):void
		{
			var show:TVShow = ConfigService.instance.getItem("s1") as TVShow;
			trace(show.producer);
			trace(ConfigService.instance.getProperty("copy"));
		}
	}
}
